function fit = fitness(x,target,tool)
lam=0.015;
fk_x=double(kuka_8dof_forwardmatics(x,tool));
fk_theta=double(target);

fit=abs(fk_x(1,1)-fk_theta(1,1))+abs(fk_x(2,1)-fk_theta(2,1))+abs(fk_x(3,1)-fk_theta(3,1))...
    +abs(fk_x(1,2)-fk_theta(1,2))+abs(fk_x(2,2)-fk_theta(2,2))+abs(fk_x(3,2)-fk_theta(3,2))...
    +abs(fk_x(1,3)-fk_theta(1,3))+abs(fk_x(2,3)-fk_theta(2,3))+abs(fk_x(3,3)-fk_theta(3,3))...
    +lam*(abs(fk_x(1,4)-fk_theta(1,4))+abs(fk_x(2,4)-fk_theta(2,4))+abs(fk_x(3,4)-fk_theta(3,4)));
end

